import { defineStore } from "pinia";
import { ref } from "vue";
export const mapStore = defineStore("mapData", () => {
  // state 变量
  const filrstList = ref([]) as any;
  const secondtList = ref([]) as any;
  //method 函数
  //设置弹窗开关
  const setFirstData = (val: any) => {
    filrstList.value = val.map((e: any) => {
      e.firstSort = e.firstSort + "";
      e.img = [
        {
          id: "1",
          name: "",
          status: "finished",
          url: e.firstPicture,
        },
      ];
      return e;
    });
  };
  //存储信息
  const setSecondData = (val: any) => {
    secondtList.value = val.map((e: any) => {
      e.secondSort = e.secondSort + "";
      e.img = [
        {
          id: "1",
          name: "",
          status: "finished",
          url: e.secondPicture,
        },
      ];
      return e;
    });
    console.log("-------");

    console.log(JSON.stringify(secondtList.value));
  };

  return {
    filrstList,
    secondtList,
    setFirstData,
    setSecondData,
  };
});
